package com.xspace.android.xafcommon.been;

import android.text.TextUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class OfflineHtmlBean {
	public OfflineHtmlBean() {
		super();
	}

	public OfflineHtmlBean(String htmlcontent, String url,String formId) {
		super();
		this.htmlcontent = htmlcontent;
		this.url = url;
		this.formId= formId;
	}

	public String htmlcontent;
	public String formId;
	public String inputdata;
	public String url;
	public String userid;
	public String sanhuid;
	public static final String CqfyContent="cqfyContent";
	public static final String SanhuInfo="sanhuInfo";
	/**cqfyContent 春秋防疫输入内容
	 *  sanhuInfo
	 *
	 * */
	public String urlType;
	public String remark;
	private HashMap<String, String> listItem;
	public HashMap<String, String> getListItem() {
		if( listItem==null){
			if(!TextUtils.isEmpty(htmlcontent))
				listItem=(HashMap<String, String>) parserToMap(htmlcontent);
			//测试散户提交数据
//			listItem=new HashMap<String, String>();
//			listItem.put("cname", "测试散户1829");
//			listItem.put("mobile", "18710501050");
//			listItem.put("fy_zhen_id", "500127001");
//			listItem.put("fy_zhen_name", "璧城街道");
//			listItem.put("fy_cun_id", "500127001200");
//			listItem.put("fy_cun_name", "四面山");
//			listItem.put("fy_she_id", "02460190a46011e592b1c81f66b90cce");
//			listItem.put("fy_she_name", "四面山村3社");

			//输入数据提交测试
//			listItem=new HashMap<String, String>();
//			listItem.put("fy_user_id", "bd383951-ca2d-41ff-a19c-7dab7bcf6593");
//			listItem.put("fy_user_name", "柯昌联");
//			listItem.put("fy_user_mobile", "13996211123");
//			listItem.put("fy_user_deptid", "d636fb12-8340-4600-9477-3454def34552");
//			listItem.put("fy_user_deptname", "防疫组");
//			listItem.put("fy_user_deptcode", "111c11d8-a451-4369-8a99-8bf161c2dc78");
//
//			listItem.put("fy_zhen_id", "500127001");
//			listItem.put("fy_zhen_name", "璧城街道");
//			listItem.put("fy_cun_id", "500127001200");
//			listItem.put("fy_cun_name", "四面山");
//			listItem.put("fy_she_id", "024623e1a46011e592b1c81f66b90cce");
//			listItem.put("fy_she_name", "四面山村3社");
//
//
//			listItem.put("mnt_username", "张某某");
//			listItem.put("fangyi_time", "2016-02-25");
//			listItem.put("cj_farm", "e61de319d5834331ad8238fc893b9df2");
//			listItem.put("cj_farm_name", "王丽萍");
//			listItem.put("owner_id", "e61de319d5834331ad8238fc893b9df2");
//			listItem.put("owner_name", "王丽萍");
//			listItem.put("owner_mobile", "15277586954");
//			listItem.put("disinfection", "1");
//			listItem.put("quarter", "1");
//			listItem.put("year", "2016");
//			listItem.put("set_user_name", "巫廷建,梁毅,江晓平,何兴胜,周琼,朱三林,王福军,柯昌联");
//			listItem.put("springFangYiLists", "[{animal_pinzhong:\"a1a08eaa-0081-470f-85d5-6a450e5c4a48\",animal_pinzhong_name:\"鸡(肉蛋兼用)\",my_zhonglei:\"b15ee8de-878e-4297-bd32-7061310d2796,2a182c14-984a-4b24-8e9e-5498e3241b63\",my_zhonglei_name:\"新城疫,禽流感\",cunlan_num:\"100\",ym_num:\"100\",my_num:\"90\"},{animal_pinzhong:\"77cf6bc6-7433-43b7-9851-8b7eb2d52028\",animal_pinzhong_name:\"鸭\",my_zhonglei:\"2a182c14-984a-4b24-8e9e-5498e3241b63\",my_zhonglei_name:\"禽流感\",cunlan_num:\"500\",ym_num:\"400\",my_num:\"400\"}]");
//
		}

		return listItem;
	}

	public static Map parserToMap(String s){
		Map map=new HashMap();
		JSONObject json;
		try {
			json = new JSONObject(s);
			Iterator keys=json.keys();
			while(keys.hasNext()){
				String key=(String) keys.next();
				String value=json.get(key).toString();
				if(value.startsWith("{")&&value.endsWith("}")){
					map.put(key, parserToMap(value));
				}else{
					map.put(key, value);
				}

			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return map;
	}
}
